<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="IE=11.0000" http-equiv="X-UA-Compatible">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <base href="<?php echo base_url();?>public/admin/" />
    <title>登录页面</title>
<style>
body {
    background: #ebebeb;
    font-family: "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei",
        "\9ED1\4F53", Arial, sans-serif;
    color: #222;
    font-size: 12px;
}

* {
    padding: 0px;
    margin: 0px;
}

a {
    text-decoration: none;
}

.top_div {
    background: #008ead;
    width: 100%;
    height: 400px;
}

.tou {
    background: url("images/tou.png") no-repeat;
    width: 97px;
    height: 92px;
    position: absolute;
    top: -87px;
    left: 140px;
}

.initial_left_hand {
    background: url("images/hand.png") no-repeat;
    width: 30px;
    height: 20px;
    position: absolute;
    top: -12px;
    left: 100px;
}

.initial_right_hand {
    background: url("images/hand.png") no-repeat;
    width: 30px;
    height: 20px;
    position: absolute;
    top: -12px;
    right: -112px;
}

.ipt {
    border: 1px solid #d3d3d3;
    padding: 10px 10px;
    width: 290px;
    border-radius: 4px;
    padding-left: 35px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
    -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow
        ease-in-out .15s;
    -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out
        .15s;
    transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s
}

.ipt:focus {
    border-color: #66afe9;
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px
        rgba(102, 175, 233, .6);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px
        rgba(102, 175, 233, .6)
}

.u_logo {
    background: url("images/username.png") no-repeat;
    padding: 10px 10px;
    position: absolute;
    top: 43px;
    left: 40px;
}

.p_logo {
    background: url("images/password.png") no-repeat;
    padding: 10px 10px;
    position: absolute;
    top: 12px;
    left: 40px;
}
</style>

</head>
<body>
    <div class="top_div"></div>
    <div style="background: rgb(255, 255, 255); margin: -100px auto auto; border: 1px solid rgb(231, 231, 231); border-image: none; width: 400px; height: 200px; text-align: center;">
        <div style="width: 165px; height: 96px; position: absolute; float:left;">
            <div class="tou"></div>
            <div class="initial_left_hand" id="left_hand"></div>
            <div class="initial_right_hand" id="right_hand"></div>
        </div>
        <p style="padding: 30px 0px 10px; position: relative;">
            <span class="u_logo"></span>
            <input class="ipt" id="username" type="text" placeholder="请输入用户名" value="">        
        </p>
        <p style="position: relative;">
            <span class="p_logo"></span>
            <input class="ipt" id="password" type="password" placeholder="请输入密码" value="">        
        </p>
        <div style="height: 50px; line-height: 50px; margin-top: 30px; border-top-color: rgb(231, 231, 231); border-top-width: 1px; border-top-style: solid;">
            <p style="margin: 0px 32px 20px 32px;">
                <span style="float: left;">
                    <!-- <a style="color: rgb(204, 204, 204);" href="#">忘记密码?</a> -->
                    <input id="remember" type="checkbox" checked="checked" style="vertical-align: middle;">
                    <label style="color: rgb(180, 180, 180); vertical-align: middle;" for="remember">记住登陆</label>
                </span>
                <span style="float: right;">
                    <!-- <a style="color: rgb(204, 204, 204); margin-right: 10px;" href="#">注册</a> -->
                    <a id="btn_login" style="background: rgb(0, 142, 173); padding: 7px 30px; border-radius: 4px; border: 1px solid rgb(26, 117, 152); border-image: none; color: rgb(255, 255, 255); font-weight: bold;" href="#">登录</a>
                </span>
            </p>
        </div>
    </div>
    <script src="../plugins/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        //登陆
        function login(){
            var url = '<?php echo site_url('ajax/user_handle/login');?>';
            var data = {};
            data.username = $('#username').val();
            data.password = $('#password').val();
            data.remember = $('#remember').prop("checked")?1:0;
            if(!data.username){ alert('请输入用户名'); return; }
            if(!data.password){ alert('请输入密码'); return; }
            $.post(url, data, function(rs){
                if(rs.err===0){
                    location.href = '<?php echo site_url('ui/index');?>';            
                }else{
                    alert(rs.msg);
                    $('#password').val('');
                }
            },'json');
        }
        $(document).ready(function () {
            //得到焦点
            $("#password").focus(function(){
                $("#left_hand").animate({
                    left: "150",
                    top: " -38"
                },{step: function(){
                    if(parseInt($("#left_hand").css("left"))>140){
                        $("#left_hand").attr("class","left_hand");
                    }
                }}, 2000);
                $("#right_hand").animate({
                    right: "-64",
                    top: "-38px"
                },{step: function(){
                    if(parseInt($("#right_hand").css("right"))> -70){
                        $("#right_hand").attr("class","right_hand");
                    }
                }}, 2000);
            });
            //失去焦点
            $("#password").blur(function(){
                $("#left_hand").attr("class","initial_left_hand");
                $("#left_hand").attr("style","left:100px;top:-12px;");
                $("#right_hand").attr("class","initial_right_hand");
                $("#right_hand").attr("style","right:-112px;top:-12px");
            });
            //注册登陆事件        
            $("#btn_login").click(function(){
                login();
                return false;
            });
            $("#password").keydown(function(event){
                if(event.which == "13") {   
                    login();
                }
            });    
        });
    </script>
</body>
</html>